<?php

namespace Drupal\youji_income_order\ViewsController;

use Drupal\youji_income_order\ViewsController\handler\field\YoujiIncomeOrderCommissionTypeViewsField;
use Drupal\youji_income_order\ViewsController\handler\field\YoujiIncomeOrderCommissionViewsField;
use Drupal\youji_income_order\ViewsController\handler\field\YoujiIncomeOrderEditLinkViewsField;
use Drupal\youji_income_order\ViewsController\handler\field\YoujiIncomeOrderStatusViewsField;
use Drupal\youji_income_order\ViewsController\handler\filter\YoujiIncomeOrderCommissionTypeViewsFilter;
use Drupal\youji_income_order\ViewsController\handler\filter\YoujiIncomeOrderStatusViewsFilter;
use EntityDefaultViewsController;


class YoujiIncomeOrderViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => YoujiIncomeOrderEditLinkViewsField::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '0 待结算 1 已结算 2 退款',
        'help' => '0 待结算 1 已结算 2 退款',
        'real field' => 'status',
        'field' => [
          'handler' => YoujiIncomeOrderStatusViewsField::class,
        ],
        'filter' => [
          'handler' => YoujiIncomeOrderStatusViewsFilter::class,
        ],
      ];
      $info[$table]['commission'] = [
        'title' => '可获佣金',
        'help' => '可获佣金',
        'real field' => 'commission',
        'field' => [
          'handler' => YoujiIncomeOrderCommissionViewsField::class,
        ],
      ];
      $info[$table]['commission_type'] = [
        'title' => '佣金类型 0 直接 1 间接',
        'help' => '佣金类型 0 直接 1 间接',
        'real field' => 'commission_type',
        'field' => [
          'handler' => YoujiIncomeOrderCommissionTypeViewsField::class,
        ],
        'filter' => [
          'handler' => YoujiIncomeOrderCommissionTypeViewsFilter::class,
        ],
      ];

      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }
}
